package com.tang.design.single;

/**
 * @author tmh
 * @date 2024/6/4 21:18
 * @description 双重校验锁的懒汉模式
 */
public class DCLSingle {
    public volatile static DCLSingle instance;

    //私有构造方法
    private DCLSingle() {
    }

    //全局访问点
    public static synchronized DCLSingle getInstance() {
        if (instance == null) {
            synchronized (DCLSingle.class) {
                if (instance == null) {
                    instance = new DCLSingle();
                }
            }
        }
        return instance;
    }
}
